FROM alpine:3.11

ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apk add --no-cache ca-certificates mailcap

RUN set -eux; \
	mkdir -p /opt/www; \
	mkdir -p \
		/config/caddy \
		/data/caddy \
		/etc/caddy \
		/usr/share/caddy \
	;

# https://github.com/caddyserver/caddy/releases
ENV CADDY_VERSION v2.0.0-rc.3

COPY ./caddy_2.0.0-rc.3_linux_amd64.tar.gz /tmp/
RUN tar x -z -f /tmp/caddy_2.0.0-rc.3_linux_amd64.tar.gz -C /usr/bin caddy; \
	rm -f /tmp/caddy_2.0.0-rc.3_linux_amd64.tar.gz; \
	chmod +x /usr/bin/caddy; \
	caddy version

# See https://caddyserver.com/docs/conventions#file-locations for details
ENV XDG_CONFIG_HOME=/config
ENV XDG_DATA_HOME=/data

VOLUME /config
VOLUME /data

LABEL org.opencontainers.image.version=v2.0.0-rc.3
LABEL org.opencontainers.image.title=Caddy
LABEL org.opencontainers.image.description="a powerful, enterprise-ready, open source web server with automatic HTTPS written in Go"
LABEL org.opencontainers.image.url=https://caddyserver.com
LABEL org.opencontainers.image.documentation=https://caddyserver.com/docs
LABEL org.opencontainers.image.vendor="Light Code Labs"
LABEL org.opencontainers.image.licenses=Apache-2.0
LABEL org.opencontainers.image.source="https://github.com/caddyserver/caddy-docker"

EXPOSE 80
EXPOSE 443
EXPOSE 2019


COPY ./www /opt/www
COPY ./conf/Caddyfile /etc/caddy/Caddyfile


CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]

